package me.j360.springboot.simple.bean.search.rule;

import me.j360.springboot.simple.bean.BaseEnum;

/**
 * 说明：
 * Bean类 - 查询条件 - 基类
 *
 * ============================================================================
 * 版权所有 2015 qiushihua。
 *
 * @author qiushihua
 * @version 0.1 2015-07-22
 * ============================================================================
 */
public abstract class Rule {

    protected final BaseEnum.RuleType ruleType;

    protected Rule(BaseEnum.RuleType ruleType) {
        this.ruleType = ruleType;
    }

    public BaseEnum.RuleType getRuleType() {
        return ruleType;
    }

    protected abstract static class Builder<T extends Rule, B extends Builder<T, B>> {

        private B theBuilder;

        protected BaseEnum.RuleType ruleType;

        public Builder () {
            theBuilder = getThis();
        }

        protected abstract B getThis();

        protected B setOperate(BaseEnum.RuleType ruleType) {
            this.ruleType = ruleType;
            return theBuilder;
        }

        public abstract T build();

    }

}
